﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DBBase;

namespace Business
{
    public partial class TerminalEquipment : Form
    {
        public TerminalEquipment()
        {
            InitializeComponent();
            getdate();
        }
        public void getdate()
        {
            lstUser.Items.Clear();
            Query objquery = new Query();
            string ssqlex = "";
            ssqlex = string.Format(@"select * from TerminalEquipment  order by EQ_ID");
            DataTable dt = objquery.GetTable(ssqlex);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ListViewItem li = new ListViewItem();
                li.SubItems[0].Text = string.Format("{0}", i + 1);
              
                li.SubItems.Add(dt.Rows[i]["EQ_name"].ToString().Trim());
                li.SubItems.Add(dt.Rows[i]["EQ_gongwei"].ToString().Trim());
                li.SubItems.Add(dt.Rows[i]["EQ_adr"].ToString().Trim());

                lstUser.Items.Add(li);
            }
        }
        private void but_save_Click(object sender, EventArgs e)
        {
            savedate();
        }
        public void savedate()
        {
            var sql = "";
            sql = string.Format(@"insert into TerminalEquipment (
                                    [EQ_name]
                                    ,[EQ_gongwei]
                                    ,[EQ_adr]) values 
                                    ('{0}',
                                    '{1}',
                                    '{2}')",
                                           com_sbmc.Text, com_sygw.Text, text_txdz.Text);
             Query objquery = new Query();
             objquery.UpdateTable(sql);
             getdate();
        }

        private void but_config_Click(object sender, EventArgs e)
        {

        }

        private void but_delete_Click(object sender, EventArgs e)
        {

        }
    }
}
